﻿using MapsterMapper;
using SSPivot.Common;
using SSPivot.Common.Cache;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;

namespace SSPivot.AspNetCore.Services
{
    public interface IApplicationService
    {
        /// <summary>
        ///  
        /// </summary>
        IMapper Mapper { get; set; }
        ICacheService Cache { get; set; }
        /// <summary>
        /// 下上文服务
        /// </summary>
        AppContextProvider AppContextProvider { get; set; }
        /// <summary>
        /// 启动事务
        /// </summary>
        /// <param name="action"></param>
        /// <param name="scopeOption"></param>
        /// <param name="isolationLevel"></param>
        void StartTransaction(Action action, TransactionScopeOption scopeOption = TransactionScopeOption.Required, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted);


        /// <summary>
        /// 启动事务
        /// </summary>
        /// <param name="func"></param>
        /// <param name="scopeOption"></param>
        /// <param name="isolationLevel"></param>
        T StartTransaction<T>(Func<T> func, TransactionScopeOption scopeOption = TransactionScopeOption.Required, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted);

    }
}
